<?php


namespace app\models\coupon;


use think\Model;

class CouponModel extends Model
{
    protected $name = 'coupon';
    protected $autoWriteTimestamp = true;


    public function setStartTimeAttr($value)
    {
        return strtotime($value);
    }

    public function getStartTimeAttr($value)
    {
        return date('Y-m-d H:i', $value);
    }

    public function setEndTimeAttr($value)
    {
        return strtotime($value);
    }

    public function getEndTimeAttr($value)
    {
        return date('Y-m-d H:i', $value);
    }

    public function setUseStartTimeAttr($value)
    {
        return strtotime($value);
    }

    public function getUseStartTimeAttr($value)
    {
        if (!$value) {
            return;
        }
        return date('Y-m-d H:i', $value);
    }

    public function setUseEndTimeAttr($value)
    {
        return strtotime($value);
    }

    public function getUseEndTimeAttr($value)
    {
        if (!$value) {
            return;
        }
        return date('Y-m-d H:i', $value);
    }

    public function getCreateTimeAttr($value)
    {
        return date('Y-m-d H:i', $value);
    }

    public function getTypeIdAttr($value)
    {
        if (!$value) {
            return;
        }
        return json_decode($value, true);
    }
}